package com.example.mobile2030606180zq0514;

import android.app.DownloadManager;
import android.app.VoiceInteractor;
import android.os.Bundle;
import android.telecom.Call;
import android.util.Log;
import android.view.textclassifier.ConversationActions;
import android.view.textclassifier.TextLanguage;
import android.view.textclassifier.TextLinks;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import java.net.ResponseCache;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainContent;
    private String url="http://192.168.1.107:3000/news";
    private OkHttpClient okHttpClient = new OkHttpClient();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        new  Thread(new Runnable() {
            @Override
            public void run() {
                Request request=new Request.Builder()
                        .url(url)
                        .build();
                Call call = okHttpClient.newCall(request);
                try {
                    Response response=call.execute();
                    String result=response.body().string();
                    Log.i("TAG",result);
                }catch (Exception e){
                    e.printStackTrace();
                }

            }
        }).start();
    }

    private void initView() {
        tvMainContent = (TextView) findViewById(R.id.tvMainContent);
    }
}